package day04;

import java.util.Scanner;

//猜数字小游戏
public class Guessing {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //从变量的声明开始，到包含它最近的大括号结束
        //int num = 250;
        int num = (int) (Math.random() * 1000 + 1);//1到1000之内的随机数
        System.out.println(num);

        int guess;
        System.out.println("猜吧！");
        do {
            //System.out.println("猜吧！");
            guess = scan.nextInt();
            if (guess > num) {
                System.out.println("猜大了，继续猜吧！");
            } else if (guess < num) {
                System.out.println("猜小了，继续猜吧！");
            } else {
                System.out.println("恭喜你猜对了(⊙o⊙)…！");
            }
        } while (guess != num);
/*
        System.out.println("猜吧！");
        int guess = scan.nextInt();//1.变量初始

        while (guess != num) {//2.循环条件
            if (guess > num) {
                System.out.println("猜大了，继续猜吧！");
            } else {
                System.out.println("猜小了，继续猜吧！");
            }
            //System.out.println("猜吧！");
            guess = scan.nextInt();//3.变量改变
        }
        System.out.println("恭喜你猜对了(⊙o⊙)!");
 */
    }
}
